﻿using System.Linq;
using WalkingTec.Mvvm.Core;

namespace SelfService.Model;

public static class BasePocoExtension
{
    public static IQueryable<T> CheckAuth<T>(this IQueryable<T> query, WTMContext wtm) where T : BasePoco
    {
        if (wtm.LoginUserInfo.Roles.Any(e => e.RoleCode == "001"))
        {
            return query;
        }
        else
        {
            return query.Where(e => e.CreateBy == wtm.LoginUserInfo.ITCode);
        }
    }
}